<?php

namespace app\Services;

use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Request;

class PvpServices
{
    private static $key = '8c85f331a4728a092bfc8dda0c3aca45';

    public static function surveys()
    {
        $client = new Client([
            'timeout'  => 100.0,
        ]);
        $headers = [
            'Authorization' => self::$key,
            'Content-Type'=>'application/json'
        ];
        $uri = 'https://surveyapi.panelviewpoint.com/ExternalSurveys/ReferenceData/SamplingService';
        $request = new Request('POST', $uri, $headers,json_encode(['CultureID'=>1],JSON_UNESCAPED_UNICODE));
        $res = $client->sendAsync($request)->wait();
        $data = json_decode($res->getBody()->getContents(),true);

        return $data;
    }


    public static function question($survey_id = '')
    {
        $client = new Client();

        $uri = 'https://surveyapi.panelviewpoint.com/GetSurveyQuotas/ReferenceData/Qualifications/'.$survey_id;
        $headers = [
            'Authorization' => self::$key,
            'Content-Type'=>'application/json'

        ];
        $request = new Request('GET', $uri, $headers,json_encode(['CultureID'=>1],JSON_UNESCAPED_UNICODE));
        $res = $client->sendAsync($request)->wait();
        $data = json_decode($res->getBody()->getContents(),true);;
        var_dump($data);
    }
}